source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin


filetype on

"动态开启和关闭工具栏
set guioptions+=m
set guioptions+=T
map <silent> <F2> :if &guioptions =~# 'T' <Bar>
        \set guioptions-=T <Bar>
        \set guioptions-=m <bar>
    \else <Bar>
        \set guioptions+=T <Bar>
        \set guioptions+=m <Bar>
    \endif<CR>

call plug#begin('~/.vim/bundle')


"最快的文件搜索器，go实现,韩国货
Plug 'junegunn/fzf'

Plug 'junegunn/fzf.vim'
"状态栏，装逼用的
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'

"mql4高亮
Plug 'vobornik/vim-mql4'

"taglist 函数列表
Plug 'vim-scripts/taglist.vim'

"文件夹浏览
"Plug 'vim-scripts/winmanager'

"彩虹括号
Plug 'luochen1990/rainbow'

"树状管理文件夹
Plug 'scrooloose/nerdtree'

"阻止刚进来就中文输入法
"Plug 'ybian/smartim'

"关灯模式
Plug 'junegunn/goyo.vim'

"异步运行插件
Plug 'skywind3000/asyncrun.vim'

"注释插件
Plug 'vim-scripts/The-NERD-Commenter'

"异步多任务插件
Plug 'neomake/neomake'
Plug 'tracyone/neomake-multiprocess'

"mql5
Plug 'rupurt/vim-mql5'

Plug 'Valloric/YouCompleteMe'  

"vue高亮插件
Plug 'posva/vim-vue'

"snow主题
Plug 'nightsense/snow'

"自定义代码片段

"快速搜索插件
Plug 'rking/ag.vim'

"js补全
"Plug 'ternjs/tern_for_vim'
call plug#end()

"color dracula
"colorscheme snow
color nachtleben
"set background=light

"gvim内部编码
set encoding=utf-8
"当前编辑的文件编码
set fileencoding=utf-8
"gvim打开支持编码的文件
set fileencodings=ucs-bom,utf-8,gbk,cp936,gb2312,big5,euc-jp,euc-kr,latin1
"set langmenu=zh_CN
"let $LANG = ‘zh_CN.UTF-8′
"解决consle输出乱码
language messages zh_CN.utf-8
"解决菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"设置终端编码为gvim内部编码encoding
let &termencoding=&encoding
"防止特殊符号无法正常显示
set ambiwidth=double
"缩进尺寸为4个空格
set sw=4
"tab宽度为4个字符
set ts=4
"编辑时将所有tab替换为空格
set et
"按一次backspace就删除4个空格了
set smarttab
"不生成备份文件,如index.html~
set nobackup
"关闭交换文件
set noswapfile
"关闭备份文件
set noundofile
"开启行号标记
set number
"开启自动缩进
set autoindent
"一键编辑配置文件
map <c-f11> :call neomakemp#run_command('gvim $MYVIMRC')<CR>

"windows全屏"
map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR> 
"共享剪切板
set clipboard=unnamed

"配置ctags，实现程序跳转
set tags=tags; 
set autochdir
"ctags键绑定CTRL+F12
"map <c-f12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr><cr>
"map <c-f10> :!ctags -R --langmap=C:+.mq5 --c++-kinds=+lpx --fields=+iaS --extra=+q .<cr><cr>
"配置taglist
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
map <c-o> :Tlist<CR>
let Tlist_GainFocus_On_ToggleOpen = 1  "打开taglist时，光标保留在taglist窗口  
"let Tlist_Show_One_File           = 1  "只显示当前文件的taglist，默认是显示多个        
"let Tlist_Exit_OnlyWindow         = 1  "如果taglist是最后一个窗口，则退出vim           
let Tlist_Use_Right_Window        = 1  "在右侧窗口中显示taglist                        
"let Tlist_GainFocus_On_ToggleOpen = 1  "打开taglist时，光标保留在taglist窗口           
"let Tlist_Auto_Open               = 1                                                  
"let Tlist_JS_Settings             = "javascript;s:string;a:array;o:object;f:function"  
"let Tlist_Ctags_Cmd               = "/usr/local/bin/ctags"  "设置ctags命令的位置      
"nnoremap <leader>tl : Tlist<CR>        "设置关闭和打开taglist窗口的快捷键 

set guifont=Sarasa\ Term\ SC:h14


nnoremap <c-e> :Buffers<CR>
let g:ctrlsf_default_root = 'cwd' "搜索默认选项
"调用ag进行搜索提升速度，同时不使用缓存文件
if executable('ag')
  set grepprg=ag\ --nogroup\ --nocolor
  let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
  let g:ctrlp_use_caching = 0
endif

"按F3即可显示或隐藏NerdTree区域了。
map <F3> :NERDTreeMirror<CR>
map <F3> :NERDTreeToggle<CR>

"--------------------Airline设置--------------------
set t_Co=256
set ttimeoutlen=50
let g:airline_theme='jellybeans'
let g:airline_powerline_fonts=1
"let g:airline#extensions#whitespace#enabled=0
"let g:airline#extensions#whitespace#symbol='!'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_detect_paste=0
let g:airline#extensions#default#section_truncate_width = {'b': 79, 'x': 60, 'y': 55, 'z': 45}
let g:airline_section_z = '%3p%% %#__accent_bold#%{g:airline_symbols.linenr} %1l%#__restore__#:%1v'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1 

""airLine显示状态
let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])


"一键保存并生效 :w 然后so %
"map <c-s>  : w! \| so %<CR>
"设置行间距
set linespace=3
"map <c-b> :w \| :call asyncrun#quickfix_toggle(10) \| AsyncRun python % <cr>
"au BufRead *.py map <buffer> <c-b> :call asyncrun#quickfix_toggle(10) \| AsyncRun python % <CR>

"解决Quickfix乱码问题
function! QfMakeConv()
       let qflist = getqflist()
       for i in qflist
          let i.text = iconv(i.text, "cp936", "utf-8")
       endfor
       call setqflist(qflist)
endfunction
 
au QuickfixCmdPost make call QfMakeConv()

"运行程序
nnoremap <f5> :call CompileRun()<cr>

func! CompileRun()
    exec "w"
    if &filetype == 'python'
        if search("@profile")
            exec "AsyncRun kernprof -l -v %"
            exec "copen"
            exec "wincmd p"
        elseif search("set_trace()")
            exec "!python %"
        else
            exec "! py -3 %"
            "exec "! python %"
            "exec "copen"
            "exec "wincmd p"
        endif
    endif
    if &filetype == 'mql5'
        exec "! metaeditor64 /compile:% /log"
        exec "AsyncRun -raw type %:r.log"
        exec "copen"
        exec "wincmd p"
    endif       
endfunc


"修改leader键
let mapleader = ","
" 高亮当前行
set cursorline
"ctermbg是设定背景色，ctermfg是设定前景色，guibg是设定下划线的背景色，guifg是设定下划线的前景色
hi CursorLine   cterm=NONE ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE
nmap <c-p> <plug>NERDComToggleComment
"自定义命令连接服务器
"command RYServer call neomakemp#run_command('putty.exe  -ssh  47.100.40.229 -l root -pw RYDJ778899$')

"显示空格和tab
"command ShowTab set listchars=tab:>-,trail:-<CR>



"''设置初始界面大小  
set lines=56 columns=120 

"=======================================fzf 配置
"设置ag搜索路径
let g:ag_prg="C:\ag\ag.exe --vimgrep"
"文件搜索
map <c-r> :FZF ./<cr>
"文本搜索
map <c-h> :Ag 
"白色主题的时候的fzf颜色配置
"autocmd VimEnter * command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, {'down': '40%', 'options': '--no-color'})


"=============================ycm配置
inoremap <expr> <CR>       pumvisible() ? "\<C-y>" : "\<CR>"	"回车即选中当前项
" 从第2个键入字符就开始罗列匹配项
let g:ycm_min_num_of_chars_for_completion=2	
